<?php
/** .-------------------------------------------------------------------
 * |  Software: [HDCMS framework]
 * |      Site: www.hdcms.com
 * |-------------------------------------------------------------------
 * |    Author: 向军 <2300071698@qq.com>
 * |    WeChat: aihoudun
 * | Copyright (c) 2012-2019, www.houdunwang.com. All Rights Reserved.
 * '-------------------------------------------------------------------*/

namespace web\admin\controller;

class Article extends Common{
    protected $db;
    public function __construct()
    {
        parent::__construct();
        $this->db = new \system\model\Article();
    }
    //文章首页
    public function index(){
        View::make();
    }
    //添加
    public function add()
    {
        if(IS_POST)
        {
            if($this->db->store())
            {
//				echo json_encode(['valid'=>1,'message'=>'操作成功']);
                //message这里如果是异步请求数据等价于上边json_encode
                message('操作成功','','success');
            }
            message($this->db->getError(),'','error');
        }
        //获取所属分类数据
        $cateData = Data::tree(Db::table("category")->get(),'cname');
        //获取标签数据
        $tagData = Db::table('tag')->get();
        View::with('cateData',$cateData)->with('tagData',$tagData)->make();
    }
}
